package com.qipay.withdraw.service;

//import com.qipay.baas.model.Banks;
import com.qipay.baas.model.Banks;
import com.qipay.baas.model.CpWithdrawTradlog;
import com.qipay.baas.model.Order;
import com.qipay.pay.entity.CpPayUnionTradeQueryRequest;
import com.qipay.security.jwt.JWTUser;
import com.qipay.withdraw.config.WithdrawQueryEnum;
import com.qipay.withdraw.service.entity.CpWithdrawRequest;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.qipay.withdraw.entity.CpBalanceQueryRequest;

import java.util.List;
import java.util.Map;

/**
 * Creator: Yao
 * Date:    2017/9/27
 * For:
 * Other:
 */
public interface WithdrawService {

    CpWithdrawTradlog get(Long withdrawId);

    int save(CpWithdrawTradlog withdraw);

    int update(CpWithdrawTradlog withdraw);

    long count(Long cpId,Byte state, String from, String to);
    long count(Long cpId);
    long countApply();

    CpWithdrawTradlog countInfo(Long cpId,Byte state, String from, String to);

    List<CpWithdrawTradlog> list(Long cpId, Byte state,String from, String to, Integer page, Integer pageSize);

    List<CpWithdrawTradlog> listByCpId(Long cpId, Byte state);

    List<Banks> findSubbranch(String province,String city,String bank);

    void fail(Long cpId, String outTradeNo, String error);

    void finish(Long cpId, String outTradeNo);

    Map<String,Object> withdrawQuery(CpPayUnionTradeQueryRequest bean, JWTUser user) throws Exception;

    @Transactional
    Map<String, Object> withdraw(CpWithdrawRequest entity, JWTUser loggedUser) throws Exception;

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    CpWithdrawTradlog createOrder(CpWithdrawRequest entity, JWTUser loggedUser);

    @Transactional
    CpWithdrawTradlog actualWithdraw(CpWithdrawRequest entity, CpWithdrawTradlog cpWithdrawTradlog)
            throws Exception;

    @Transactional
    CpWithdrawTradlog createWithdrawOrder(CpWithdrawRequest entity);

    @Transactional
    void setWithdrawSuccess(CpWithdrawTradlog cpWithdrawTradlog);

    @Transactional
    void setWithdrawFail(CpWithdrawTradlog cpWithdrawTradlog);

    Map<String, Object> queryBalance(CpBalanceQueryRequest entity, JWTUser loggedUser) throws Exception;

    @Transactional(propagation = Propagation.NESTED)
    boolean withdrawFromBank(Order order, CpWithdrawRequest entity) throws Exception;

    List<CpWithdrawTradlog> list(String from, String to);
    List<CpWithdrawTradlog> list(Byte state);
    void updateState(Long id);
 ///   Banks selectAll(Banks banks);
    CpWithdrawTradlog findByOutTradeNo (String outTradeNo);


   // List<CpWithdrawTradlog> listBy(Map<String, Object> params);
    //List<CpWithdrawTradlog> selectall(CpWithdrawTradlog cpWithdrawTradlog);
}
